﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using BackAgent.GeoCodeService1;
using System.Device.Location;
using Microsoft.Phone.Controls.Maps;
using Microsoft.Phone.Controls;
using System.IO.IsolatedStorage;
using System.Threading;


namespace BackAgent
{

    public class Geo 
    {
          
        public void whereamI()
        {
            try
            {
                GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();
                if (watcher != null)
                {
                    watcher.TryStart(false, TimeSpan.FromMilliseconds(1000));
                    GeoCoordinate coord = watcher.Position.Location;
                    if (coord.IsUnknown != true)
                    {
                        IsolatedSettings.saveSettings("lat", coord.Latitude.ToString());
                        IsolatedSettings.saveSettings("long", coord.Longitude.ToString());
                    }
                }
                
                watcher.Stop();
            }
            catch (Exception e)
            {
                
            }
        }
      
    }
}
